<template>
  <div class="container">
    <el-form :model="form">
      <h2> {{ form.title  }} </h2>
      <div class="tags">
        <span> {{ form.createTime }} </span>
        <span> {{ form.username }} </span>
        <span class="el-icon-view"></span>
        <span> {{ form.visits }} </span>
      </div>
      <div ref="content" class="content">
        {{ form.articleBody }}
      </div>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'articlesPreview',
  props: {
    row: {
      type: Object,
      default: () => {}
    }
  },
  data () {
    return {
      form: {
        id: '',
        title: '',
        articleBody: '',
        videoURL: '',
        reads: '',
        state: '',
        creator: '',
        createTime: '',
        username: ''
      }
    }
  },
  created () {
    // console.log(this.row, 12222)
    this.form = this.row
  },
  watch: {
    form: {
      handler () {
        if (this.$refs.content) return
        // console.log(this.$refs.content)
        this.$nextTick(() => {
          this.$refs.content.innerHTML = this.form.articleBody
        })
      },
      immediate: true,
      deep: true
    }
  }
}
</script>

<style scoped lang="scss">
.container {
  ::v-deep {
    img {
      max-width: 100%;
    }
  }

}
.tags {
  margin: 20px;
}
.content {
  min-height: 80px;
  background-color: #f5f5f5;
}
span {
  margin: 0 5px;
}
</style>
